#define _CRT_SECURE_NO_WARNINGS 1
struct TreeNode* invertTree(struct TreeNode* root) {
    if (!root)
        return NULL;

    struct TreeNode* left = invertTree(root->left);
    struct TreeNode* right = invertTree(root->right);
    root->left = right;
    root->right = left;

    return root;
}


bool isSameTree(struct TreeNode* p, struct TreeNode* q) {
    if (p == NULL && q == NULL)
    {
        return true;
    }
    else if (p == NULL || q == NULL)
    {
        return false;
    }
    else if (p->val != q->val)
    {
        return false;
    }
    else
    {
        return isSameTree(p->left, q->left) && isSameTree(q->right, p->right);
    }
}

bool isSubtree(struct TreeNode* root, struct TreeNode* subRoot)
{
    if (!root)
        return false;
    return isSameTree(root, subRoot)
        || isSubtree(root->left, subRoot)
        || isSubtree(root->right, subRoot);
}

